import { _decorator, Component, Node } from "cc";
import { BeginInterfaceManager } from "db://assets/Scripts/Manager/BeginInterfaceManager";
import { RegPageManager } from "db://assets/Scripts/Manager/RegPageManager";
import { BattleFieldManager } from "db://assets/Scripts/Manager/BattleFieldManager";
import { CommonUtil } from "db://assets/Scripts/Utils/CommonUtil";
import { SceneMgrAssist } from "db://assets/Scripts/Assist/SceneMgrAssist";
const { ccclass, property } = _decorator;

@ccclass("SceneManager")
export class SceneManager extends Component {
  beginInterNode: Node;
  regPageNode: Node;
  battleFieldNode: Node;
  sceneMgrAssist: SceneMgrAssist;
  commonUtil: CommonUtil;
  nodesArray: Node[];

  constructor() {
    super();
    this.commonUtil = CommonUtil.getInstance();
  }

  initializeContainer() {
    const beginInterComp = this.node.addComponent(BeginInterfaceManager);
    beginInterComp.initBeginInterface();
    this.beginInterNode = beginInterComp.localBeginNode;

    const regPageComp = this.node.addComponent(RegPageManager);
    regPageComp.initialization();
    this.regPageNode = regPageComp.localRegisterNode;

    const battleFieldComp = this.node.addComponent(BattleFieldManager);
    battleFieldComp.initialzeField();
    this.battleFieldNode = battleFieldComp.localBattleField;

    this.nodesArray = [
      this.beginInterNode,
      this.regPageNode,
      this.battleFieldNode,
    ];
  }

  loadingNode() {
    this.sceneMgrAssist = this.node.addComponent(SceneMgrAssist);
    this.sceneMgrAssist.parentClass = this;
  }

  start() {
    this.initializeContainer();
    this.loadingNode();
    console.info(this.node);
  }
}
